/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package frm.billingAndPaymentProcessing.session;

import frm.billingAndPaymentProcessing.entity.ReceiptEntity;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author xhx
 */
@Stateless
@LocalBean
public class ReceiptSessionBean {

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    @PersistenceContext
    private EntityManager em;
    
    private ReceiptEntity receipt;
    

   public void createReceipt(ReceiptEntity receipt){
      em.persist(receipt);
}  
   public ReceiptEntity getReceiptById(Long receiptId){
       return em.find(ReceiptEntity.class, receiptId);
   }
   public List<ReceiptEntity> getAllReceipt(){
        Query query = em.createQuery("SELECT u FROM ReceiptEntity u");
        return query.getResultList();
   }
   public void saveChanges(ReceiptEntity receipt){
       em.merge(receipt);
   }

    public ReceiptEntity getReceipt() {
        return receipt;
    }

    public void setReceipt(ReceiptEntity receipt) {
        this.receipt = receipt;
    }
   
}